<?php
include_once 'admin/includes/functions/admin-functions.php';
global  $CONFIG,$SMARTY,$DBobject;

if(empty($_SESSION['user']['admin'])){
  header("location: https://www.readysteadygokids.com.au/admin/login");
  die();
}

if(!empty($_GET['show_all'])){
	$SMARTY->assign('show_all',$_GET['show_all']);
}

if(!empty($_GET['q'])){
	$data = array();
	$sql = "SELECT DISTINCT(listing_object_id) FROM tbl_messageboard WHERE 
						( EXISTS (SELECT DISTINCT(tag_object_id) FROM tbl_tag WHERE tag_value = :value AND tag_deleted IS NULL AND tag_object_id > 0 AND tag_object_table = 'tbl_messageboard' AND listing_object_id = tag_object_id) 
						OR listing_content1 LIKE :listing_content1)
						AND listing_deleted IS NULL AND listing_published = 1 AND listing_parent_id = 0 AND listing_type_id = 9";
	if($res = $DBobject->wrappedSql($sql, array(":value"=>$_GET['q'], ":listing_content1"=>"%{$_GET['q']}%"))){
	  foreach ( $res as $r) {
	  	$data[] = $r['listing_object_id'];
	  }
	}
	$SMARTY->assign('query',$_GET['q']);
	$SMARTY->assign('count',count($data));
	$SMARTY->assign('results',$data);
}


